package com.weipai.springboot.module.dao.impl;

import com.weipai.springboot.model.*;
import com.weipai.springboot.module.dao.PersonalDao;
import com.weipai.springboot.module.mapper.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @Author: 曹朋飞
 * @Date: 2018/08/27 11:21
 */
@Repository
public class PersonalDaoImpl implements PersonalDao{

    @Autowired
    private DemandMapper demandMapper;
    @Autowired
    private DemandCategoryMapper demandCategoryMapper;
    @Autowired
    private ShopMapper shopMapper;
    @Autowired
    private ShopCategoryMapper shopCategoryMapper;
    @Autowired
    private CustomerFeedbackMapper customerFeedbackMapper;
    @Autowired
    private GiftCertificateMapper giftCertificateMapper;
    @Autowired
    private CustomerGiftMapper customerGiftMapper;
    @Autowired
    private CustomerEvaluateMapper customerEvaluateMapper;
    @Autowired
    private CustomerIntegralMapper customerIntegralMapper;
    
    //获取用户的需求
    @Override
    public List<Map<String, Object>> getDemandByCustomerId(String customerId) {
        return demandMapper.getDemandByCustomerId(customerId);
    }

    //添加需求
    @Override
    public int saveDemand(Demand demand) {
        return demandMapper.insertSelective(demand);
    }

    //获取需求分类
    @Override
    public List<Map<String, Object>> getDemandCategory() {
        return demandCategoryMapper.getDemandCategory();
    }

    //申请店铺
    @Override
    public int applyForShop(Shop shop) {
        return shopMapper.insertSelective(shop);
    }

    //获取店铺分类
    @Override
    public List<Map<String, Object>> getShopCategory() {
        return shopCategoryMapper.getShopCategory();
    }

    //用户反馈
    @Override
    public int saveCustomerFeedBack(CustomerFeedback feedback) {
        return customerFeedbackMapper.insert(feedback);
    }

    //用户的优惠券
    @Override
    public List<Map<String, Object>> getCustomerGift(String customerId, Integer status, Integer start, Integer size) {
        return giftCertificateMapper.getCustomerGift(customerId, status, start, size);
    }

    //用户的优惠券的总数量
    @Override
    public Integer getCustomerGiftAmount(String customerId, Integer status) {
        return giftCertificateMapper.getCustomerGiftAmount(customerId, status);
    }

    //验证用户是否领取过
    @Override
    public Integer verifiCustomerGift(String customerId, String giftId) {
        return customerGiftMapper.verifiCustomerGift(customerId, giftId);
    }

    //领取优惠券
    @Override
    public int saveCustomerGift(CustomerGift customerGift) {
        return customerGiftMapper.insert(customerGift);
    }

    //保存评论
    @Override
    public int saveEvaluate(CustomerEvaluate evaluate) {
        return customerEvaluateMapper.insert(evaluate);
    }

    //获取用户的积分记录
    @Override
    public List<Map<String, Object>> getCustomerIntegralInfo(String customerId) {
        return customerIntegralMapper.getCustomerIntegralInfo(customerId);
    }
}
